﻿package  {
	
	public class Film {
		
		// Constants:
		const MAXSUCCESSOR:Number = 3;
		// Public Properties:
		// Private Properties:
		var name:String;
		var path:String;
		var successors:Array;
		var key_successors:Array; // Définir la clé pour appeler le successor correspondent dans la table successors
								  // code liste se trouve http://www.dakmm.com/?p=272	
		var predecessor:Film;
		var begin_listen:Number = -1; // on entend l'action à la fin de la vidéo
		var end_listen:Number = -1; // on entend l'action à la fin de la vidéo
		var is_over:Boolean = false;
		var defaultSuccessor:Number;

	
		// Initialization:
		public function Film() { 
			successors = new Array();
			key_successors = new Array();
		}
	
		// Public Methods:
		public function setName(n:String):void {
			name = n;
		}
		
		public function getName():String {
			return name;
		}
		
		public function setPath(p:String):void {
			path = p;
		}
		
		public function addSuccessor(f:Film):void {
			successors.push(f);
		}
		
		public function getSuccessors(): Array {
			return successors;
		}
		
		
		public function getPath():String {
			return path;
		}
		
		
		public function isOver():Boolean {
			return is_over;
		}
		
		public function setOver(p:Boolean):void {
			is_over = p;
		}
		
		
		public function getSuccessor(index:Number):Film {
			var i:Number= 0;
			var f:Film;
			for (var ii in successors) {
				i++;
				if (i == index) {
					f = successors[ii];
				}
			}
			return f;
		}
		
		public function setListenPeriod(b:Number, e:Number):void {
			begin_listen = b;
			end_listen = e;
		}
		
		public function getBeginListen():Number {
			return begin_listen;
		}
		
		public function getEndListen():Number {
			return end_listen;
		}
		
		public function setSuccessorKey(key:Number):void {
			key_successors.push(key);
		}
		
		public function getSuccessorKey(index:Number):Number {
			var i:Number= 0;
			var key:Number;
			for (var ii in key_successors) {
				i++;
				if (i == index) {
					key = key_successors[ii];
				}
			}
			return key;
		}
		
		public function setDefaultSuccessor(f:Number):void {
			defaultSuccessor = f;
		}
		
		public function getDefaultSuccessor(): Film {
			return getSuccessor(defaultSuccessor);
		}
		// Protected Methods:
		

	}
	
}